<!doctype html>
<html>

	<head>
		<meta charset="UTF-8" />
		<title>添加银行卡</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/mui.css" />
		<link rel="stylesheet" href="../css/reg.css" />
		<script src="../js/mui.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" href="../css/common.css" />
		<script type="text/javascript">
			mui.init();
			if (location.pathname != "/h5/html/login.html" && typeof(sessionStorage.token) == "undefined") {

				mui.openWindow({
					url: 'login.html',

				});
			}
		</script>
		<script type="text/javascript" src="../js/common.js"></script>
	</head>

	<body>
		<div class="mui-content">
			<form class="mui-input-group">
				<div class="mui-input-row">
					<label>开户银行</label>
					<select id="bank">
							  <option value="none">请选择开户银行</option>
							  <!--<option value="">中国银行</option>-->
							 
			 		 </select>
					<img src="../images/bottom.png" style="position: absolute;right: 1rem;top: 0.1rem;width: 24px;height: 24px;" />
				</div>

				<div class="mui-input-row">
					<label>开户名称</label>
					<input type="text" class="mui-input-clear identifyName" placeholder="请输入开户人姓名">
				</div>

				<div class="mui-input-row">
					<label>证件号码</label>
					<input type="text" class="mui-input-clear identifyNumber" placeholder="请输入开户人证件号码">
				</div>
				<div class="mui-input-row">
					<label>开户账号</label>
					<input type="text" class="mui-input-clear bankCard" placeholder="请输入银行账号">
				</div>
				<div class="mui-input-row">
					<label>手机号码</label>
					<input type="text" class="mui-input-clear mobile" placeholder="请输入开户人联系号码">
				</div>
			</form>
			<div class="mui-content-padded">
				<button id='reg' class="mui-btn mui-btn-block mui-btn-primary">保存</button>
			</div>
		</div>

	</body>

</html>
<script>
	mui.ajax("/api/v1/bank/allCardList", {
		data: {
			paramStr: "{'userName':'" + sessionStorage.userName + "','token':'" + sessionStorage.token + "'}"
		},
		dataType: 'json',
		type: 'post',
		success: function(data) {
			var obj = eval('(' + data.data + ')');
			var bank = document.querySelector("#bank");
			var i;
			for (i in obj.allCardList) {
				var option = document.createElement("option");
				option.value = obj.allCardList[i].id;
				bank.appendChild(option);
				option.innerHTML = obj.allCardList[i].name;
			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			mui.toast("未知错误1");
		}
	});
	//拉取常用银行卡列表
	document.querySelector("#reg").addEventListener("tap", function() {
		var bankId = document.querySelector("#bank").value;
		var bankCard = document.querySelector(".bankCard").value;
		var identifyNumber = document.querySelector(".identifyNumber").value;
		var identifyName = document.querySelector(".identifyName").value;
		var mobile = document.querySelector(".mobile").value;
		mui.ajax("/api/v1/bank/add", {
			data: {
				paramStr: "{'userName':'" + sessionStorage.userName + "','token':'" + sessionStorage.token + "','isMerchant':'" + sessionStorage.isMerchant+ "','bankId':'" + bankId + "','bankCard':'" + bankCard + "','identifyNumber':'" + identifyNumber + "','identifyName':'" + identifyName + "','mobile':'" + mobile + "'}"
			},
			dataType: 'json',
			type: 'post',
			success: function(data) {
				mui.alert(data.message,jump);
				function jump(){
					mui.openWindow({
							url: '../index.html',
					});
				}

			},
			error: function(xhr, type, errorThrown) {
				//异常处理；
				mui.toast("未知错误2");
			}
		});

	});
</script>